package com.open.capacity.tenant.controller;

import com.open.capacity.common.web.Result;
import com.open.capacity.log.annotation.LogAnnotation;
import com.open.capacity.tenant.config.DataSourceConfiguration;
import com.open.capacity.tenant.model.CreateTenantDto;
import com.open.capacity.tenant.service.TenantService;
import feign.Param;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 租户注册控制层
 * @program: open-capacity-platform
 * @author: GuoGaoJu
 * @create: 2023-03-20
 **/
@Slf4j
@RestController
@RequestMapping(value = "/tenant")
@Api(value = "租户控制层")
@Valid
public class TenantController {

    @Autowired
    private DataSourceConfiguration dataSourceConfiguration;

    @Autowired
    private TenantService tenantService;

    @ApiOperation(value = "注册租户")
    @PostMapping("/tenant")
    @LogAnnotation(module = "tenant-server",recordRequestParam = false)
    public Result saveTenant(@RequestBody @Valid CreateTenantDto createTenantDto){
        return Result.succeed(tenantService.saveTenant(createTenantDto));
    }

}
